package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.CuisineDao;
import com.cn.wanxi.model.CuisineModel;
import com.cn.wanxi.util.JDBC;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CuisineImpl implements CuisineDao {
    @Override
    public List<CuisineModel> findAll(CuisineModel model) {
        String sql = "select * from cuisine where is_show=1";
        ResultSet resultset = JDBC.query(sql);
        List<CuisineModel> list = new ArrayList<>();
        try {
            while (resultset.next()) {
                CuisineModel cuisineModel = new CuisineModel();
                cuisineModel.setId(resultset.getInt("id"));
                cuisineModel.setName(resultset.getString("name"));
                cuisineModel.setTitle(resultset.getString("name"));
                list.add(cuisineModel);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return list;
    }
}
